#!/usr/bin/env python

from SocketServer import TCPServer, ForkingMixIn, StreamRequestHandler

class Server(ForkingMixIn, TCPServer): pass

class Handler(StreamRequestHandler):
	def handle(self):
		addr = self.request.getpeername()
		print 'Got connection from ', addr
		self.wfile.write('Thank you for connecting')

def main():
	port = 3121
	server = Server(('', port), Handler)
	print 'Server is listening on ', port
	server.serve_forever()

if __name__ == "__main__":
    main()